{include file="./headStart.tpl"}
{literal}
<script type="text/javascript">
$(document).ready(function() {
  $(".technicianId").change(function(){
    technician1Change($(this));
    slotChange1($(this));
  });
});
//validation code
function formvalidation()
{
	var data1 = $(".technicianId").val();
	//var data2 = $(".timeSlotId1").val();
     if(data1 == 0)
     {
       alert("Technician is not selected");
       $(".technicianId").focus();
       return false;
     }
     //if(data2 == 0)
     if($('.timeSlotId1 option:selected').length == 0)
     {
       alert("Slot is not selected");
       $(".timeSlotId1").focus();
       return false;
     }
}

//check,Uncheck timeslot1
function timeSlot1check()
{
  if(document.form.timeSlot1Check.checked == true)
  {
    var aSelect = document.form.timeSlotId1;
    var aSelectLen = aSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      aSelect.options[i].selected = true;
    }
  }
  else if(document.form.timeSlot1Check.checked == false)
  {
    var checkSelect = document.form.timeSlotId1;
    var aSelectLen = checkSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      checkSelect.options[i].selected = false; 
    }
  }
}
//check,Uncheck timeslot2
function timeSlot2check()
{
  if(document.form.timeSlot2Check.checked == true)
  {
    var aSelect = document.form.timeSlotId2;
    var aSelectLen = aSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      aSelect.options[i].selected = true;
    }
  }
  else if(document.form.timeSlot1Check.checked == false)
  {
    var checkSelect = document.form.timeSlotId2;
    var aSelectLen = checkSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      checkSelect.options[i].selected = false; 
    }
  }
}
//check,Uncheck timeslot3
function timeSlot3check()
{
  if(document.form.timeSlot3Check.checked == true)
  {
    var aSelect = document.form.timeSlotId3;
    var aSelectLen = aSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      aSelect.options[i].selected = true;
    }
  }
  else if(document.form.timeSlot3Check.checked == false)
  {
    var checkSelect = document.form.timeSlotId3;
    var aSelectLen = checkSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      checkSelect.options[i].selected = false; 
    }
  }
}
//check,Uncheck timeslot4
function timeSlot4check()
{
  if(document.form.timeSlot4Check.checked == true)
  {
    var aSelect = document.form.timeSlotId4;
    var aSelectLen = aSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      aSelect.options[i].selected = true;
    }
  }
  else if(document.form.timeSlot4Check.checked == false)
  {
    var checkSelect = document.form.timeSlotId4;
    var aSelectLen = checkSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      checkSelect.options[i].selected = false; 
    }
  }
}
//check,Uncheck timeslot5
function timeSlot5check()
{
  if(document.form.timeSlot5Check.checked == true)
  {
    var aSelect = document.form.timeSlotId5;
    var aSelectLen = aSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      aSelect.options[i].selected = true;
    }
  }
  else if(document.form.timeSlot5Check.checked == false)
  {
    var checkSelect = document.form.timeSlotId5;
    var aSelectLen = checkSelect.length;
    for(i = 0; i < aSelectLen; i++) {
      checkSelect.options[i].selected = false; 
    }
  }
}
// To change Technician  : Starts
function technician1Change(theObj) 
{
  var dataString = "technicianId=" + $(theObj).val();
  $.ajax({
    url: "./techAllocationAj.php",
    cache: false,
    data: dataString,
    success:function(data){
    	 $("#technicianId2").html(data);
    	 $(".technicianId2").change(function(){
         technician2Change($(this));
         slotChange2($(this));
       });
    }
  });
}
function slotChange1(theObj) 
{
  var slotdataString = "technicianId=" + $(theObj).val() + "&targeteYear=" + $("select[name='targetedDateYear']").val() 
                      + "&targeteMonth=" + $("select[name='targetedDateMonth']").val() + "&targeteDay=" + $("select[name='targetedDateDay']").val();
  $.ajax({
    url: "./timeSloteAj.php",
    cache: false,
    data: slotdataString,
    success:function(data){
    	 $("#timeSlotId1").html(data);
       }
     });
}
function technician2Change(theObj) 
{
  var dataString1 = "technicianId=" + $(".technicianId").val() + "&technicianId2=" + $(theObj).val();
  $.ajax({
    url: "./techAllocationAj.php",
    cache: false,
    data: dataString1,
    success:function(data){
    	 $("#technicianId3").html(data);
    	 $(".technicianId3").change(function(){
         technician3Change($(this));
         slotChange3($(this));
       });
    }
  });
}
function slotChange2(theObj) 
{
  var slotdataString1 = "technicianId=" + $(theObj).val() + "&targeteYear=" + $("select[name='targetedDateYear']").val() 
                      + "&targeteMonth=" + $("select[name='targetedDateMonth']").val() + "&targeteDay=" + $("select[name='targetedDateDay']").val();
  $.ajax({
    url: "./timeSloteAj.php",
    cache: false,
    data: slotdataString1,
    success:function(data){
    	 $("#timeSlotId2").html(data);
       }
     });
}
function technician3Change(theObj) 
{
  var dataString2 = "technicianId=" + $(".technicianId").val() + 
                    "&technicianId2=" + $(".technicianId2").val() +
                    "&technicianId3=" + $(theObj).val();
  $.ajax({
    url: "./techAllocationAj.php",
    cache: false,
    data: dataString2,
    success:function(data){
    	 $("#technicianId4").html(data);
    	 $(".technicianId4").change(function(){
         technician4Change($(this));
         slotChange4($(this));
       });
    }
  });
}
function slotChange3(theObj) 
{
  var slotdataString2 = "technicianId=" + $(theObj).val() + "&targeteYear=" + $("select[name='targetedDateYear']").val() 
                      + "&targeteMonth=" + $("select[name='targetedDateMonth']").val() + "&targeteDay=" + $("select[name='targetedDateDay']").val();
  $.ajax({
    url: "./timeSloteAj.php",
    cache: false,
    data: slotdataString2,
    success:function(data){
    	 $("#timeSlotId3").html(data);
       }
     });
}
function technician4Change(theObj) 
{
  var dataString3 = "technicianId=" + $(".technicianId").val() +
                    "&technicianId2=" + $(".technicianId2").val() +  
                    "&technicianId3=" + $(".technicianId3").val()+
                    "&technicianId4=" + $(theObj).val();
  $.ajax({
    url: "./techAllocationAj.php",
    cache: false,
    data: dataString3,
    success:function(data){
    	 $("#technicianId5").html(data);
    	 $(".technicianId5").change(function(){
    	 slotChange5($(this));
    	});
    }
  });
}
function slotChange4(theObj) 
{
  var slotdataString4 = "technicianId=" + $(theObj).val() + "&targeteYear=" + $("select[name='targetedDateYear']").val() 
                      + "&targeteMonth=" + $("select[name='targetedDateMonth']").val() + "&targeteDay=" + $("select[name='targetedDateDay']").val();
  $.ajax({
    url: "./timeSloteAj.php",
    cache: false,
    data: slotdataString4,
    success:function(data){
    	 $("#timeSlotId4").html(data);
       }
     });
}
function slotChange5(theObj) 
{
  var slotdataString5 = "technicianId=" + $(theObj).val() + "&targeteYear=" + $("select[name='targetedDateYear']").val() 
                      + "&targeteMonth=" + $("select[name='targetedDateMonth']").val() + "&targeteDay=" + $("select[name='targetedDateDay']").val();
  $.ajax({
    url: "./timeSloteAj.php",
    cache: false,
    data: slotdataString5,
    success:function(data){
    	 $("#timeSlotId5").html(data);
       }
     });
}
function goBack()
{
  window.history.back()
}
</script>
{/literal}
{include file="./headEnd.tpl"}
<input type="button" value="Back" class="table2" onclick="goBack()" style="cursor:pointer;"/> 
<form action="{$smarty.server.PHP_SELF}" name="form" method="POST" id="form1">
<input type="hidden" name="" value="" />
<table border='0' cellpadding='1' cellspacing='2' align='center'>
<tr>
  <td class="table1" align="center" colspan="14"><font style="font-size: 16px"><b> Technician Allocation Process </b></font></td>
</tr>
<tr>
  <!--td class="table1" align="center">&nbsp;</td>
  <td class="table1" align="center">&nbsp;</td-->
	<td class="table1" align='center'><B>Sr <br />No.</td>
	<td class="table1" align='center'><B>Call Type</td>
	<td class="table1" align='center'><B>Customer</td>
	<td class="table1" align='center'><B>Set Date</td>
	<td class="table1" align='center'><B>Technician 1 </td>
	<td class="table1" align='center'><B>Slot</td>
	<td class="table1" align='center'><B>Technician 2 </td>
	<td class="table1" align='center'><B>Slot</td>
	<td class="table1" align='center'><B>Technician 3 </td>
	<td class="table1" align='center'><B>Slot</td>
	<td class="table1" align='center'><B>Technician 4 </td>
	<td class="table1" align='center'><B>Slot</td>
	<td class="table1" align='center'><B>Technician 5 </td>
	<td class="table1" align='center'><B>Slot</td>
</tr>
{section name="sec" loop=$complainCallDetailArray}
<tr>
   <input type="hidden" name="complainServiceId" id="complainServiceId" value="{$complainCallDetailArray[sec].complainServiceId}">
   <input type="hidden" name="newInstallationMasterId" id="complainServiceId" value="{$complainCallDetailArray[sec].newinstallationMasterId}">
   <input type="hidden" name="otherServiceId" id="otherServiceId" value="{$complainCallDetailArray[sec].otherServiceId}">
	<!--td class="table2" align="center">
	  <a href="complainService.php?complainServiceId={$complainCallDetailArray[sec].complainServiceId}" class="link"><img src="./images/b_edit.png" border="0" width="15" height="15" title="Edit"></a>
	</td>
	<td>  
		<a href="complainCallListDelete.php?complainServiceId={$complainCallDetailArray[sec].complainServiceId}" class="link" onclick="return confirm('Are You Sure?');"><img src="./images/deleteIcon.png" border="0" width="15" height="15" title="Delete"></a>
	</td-->
	<td class="table2" align="center">{$smarty.section.sec.rownum}</td>
	<td class="table2" align="center">{$complainCallDetailArray[sec].typeOfCall}</td>
	<td class="table2" id="tooltip" align="left">{$complainCallDetailArray[sec].companyName}
	  <span>{$complainCallDetailArray[sec].description}</span>
	  </td>
	<td class="table2" NOWRAP>
		{html_select_date prefix="targetedDate" time={$complainCallDetailArray[sec].listedDate} start_year="-3" end_year="+1" field_order="DMY" month_format="%m" 
		day_value_format="%02d"}
	</td>
	<td class="table2">
	  <select name="technicianId1" id="technicianId" class="technicianId">
	    <option value="0">Technician Name</option>
	    {html_options values=$technicianId output=$technicianName}
	  </select>
	  <div></div>
	</td>
	<td class="table2">
		<input type="checkbox" name="timeSlot1Check" id="timeSlot1Check" onclick="timeSlot1check()"/>All
	 <select name="timeSlotId1[]" id="timeSlotId1" class="timeSlotId1" MULTIPLE>
	    {html_options values=$timeSlotId output=$slotName}
	  </select>
	</td>
	<td class="table2" id="tableSpan">
	  <select name="technicianId2" id="technicianId2" class="technicianId2">
	    <option>Technician Name</option>
	  </select>
	</td>
	<td class="table2">
		<input type="checkbox" name="timeSlot2Check" id="timeSlot2Check" onclick="timeSlot2check()"/>All
	  <select name="timeSlotId2[]" id="timeSlotId2" MULTIPLE>
	    {html_options values=$timeSlotId output=$slotName}
	  </select>
	</td>
	<td class="table2">
	  <select name="technicianId3" id="technicianId3" class="technicianId3">
	    <option>Technician Name</option>
	  </select>
	</td>
	<td class="table2">
		<input type="checkbox" name="timeSlot3Check" id="timeSlot3Check" onclick="timeSlot3check()"/>All
	  <select name="timeSlotId3[]" id="timeSlotId3" MULTIPLE>
	    {html_options values=$timeSlotId output=$slotName}
	  </select>
	</td>
	<td class="table2">
	  <select name="technicianId4" id="technicianId4" class="technicianId4">
	    <option>Technician Name</option>
	  </select>
	</td>
	<td class="table2">
		<input type="checkbox" name="timeSlot4Check" id="timeSlot4Check" onclick="timeSlot4check()"/>All
	  <select name="timeSlotId4[]" id="timeSlotId4" MULTIPLE>
	    {html_options values=$timeSlotId output=$slotName}
	  </select>
	</td>
	<td class="table2">
	  <select name="technicianId5" id="technicianId5" class="technicianId5">
	    <option>Technician Name</option>
	  </select>
	</td>
	<td class="table2">
		<input type="checkbox" name="timeSlot5Check" id="timeSlot5Check" onclick="timeSlot5check()"/>All
	  <select name="timeSlotId5[]" id="timeSlotId5" MULTIPLE>
	    {html_options values=$timeSlotId output=$slotName}
	  </select>
	</td>
</tr>
<form id="form2">
<tr>
	<td class="table1" colspan="14" align="center">
	  <input type="submit" name="submitBtn" id="submitBtn" class="submitBtn" value=" Set" onclick="return formvalidation(this);"/>
	</td>
</tr>
<form>
{sectionelse}
  <tr><td align="center" colspan="6"> <h2><font color="red"><b>{$msg}</b></font></h2></td></tr>
{/section}
</tr>
</table>
</form>
<br />
<table border='0' cellpadding='1' cellspacing='2' align='center'>
<tr>
  <td class="table1" align="center" colspan="14"><font style="font-size: 16px"><b> Technician Allocated List </b></font></td>
</tr>
<tr>
	<td class="table1" align='center'><B>Sr. No.</td>
	<td class="table1" align='center'><B>Call Type</td>
	<td class="table1" align='center'><B>Customer</td>
	<td class="table1" align='center'><B>Targeted Date</td>
	<td class="table1" align='center'><B>Technician 1</td>
	<td class="table1" align='center'><B>Technician 2</td>
	<td class="table1" align='center'><B>Technician 3</td>
	<td class="table1" align='center'><B>Technician 4</td>
	<td class="table1" align='center'><B>Technician 5</td>
</tr>
{section name="sec" loop=$techAllocatedArray}
<tr>
  <td class="table3" align="center">{$smarty.section.sec.rownum}</td>
  <td class="table3" align="center">{$techAllocatedArray[sec].callType}</td>
  <td class="table3" align="center" id="tooltip">{$techAllocatedArray[sec].companyName}
  	<span>
  		{$techAllocatedArray[sec].contactPerson1} : {$techAllocatedArray[sec].mobile1}
    </span>
  </td>
  <td class="table3" align="center">{$techAllocatedArray[sec].targetedDate}</td>
  <td class="table3" align="center" id="tooltip">{$techAllocatedArray[sec].technicianName1}
    <span>SLOT : {$techAllocatedArray[sec].slotName1}</span>
  </td>
  <td class="table3" align="center" id="tooltip">{$techAllocatedArray[sec].technicianName2}
    <span>SLOT : {$techAllocatedArray[sec].slotName2}</span>
  </td>
  <td class="table3" align="center" id="tooltip">{$techAllocatedArray[sec].technicianName3}
    <span>SLOT : {$techAllocatedArray[sec].slotName3}</span>
  </td>
  <td class="table3" align="center" id="tooltip">{$techAllocatedArray[sec].technicianName4}
    <span>SLOT : {$techAllocatedArray[sec].slotName4}</span>
  </td>
  <td class="table3" align="center" id="tooltip">{$techAllocatedArray[sec].technicianName5}
    <span>SLOT : {$techAllocatedArray[sec].slotName5}</span>
  </td>
</tr>
{sectionelse}
  <tr><td align="center" colspan="6"> <h2><font color="red"><b>{$msg}</b></font></h2></td></tr>
{/section}
</table>
{include file="footer.tpl"}